<template>
  <div>
    <el-form :model="form">
      <el-form-item label="Parent's Son" prop="parent.son">
        <el-input v-model="form.parent.son"></el-input>
      </el-form-item>
      <el-form-item label="Name" prop="name">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">Submit</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { validate } from 'async-validator'

export default {
  data() {
    return {
      form: {
        parent: {
          son: ''
        },
        name: ''
      }
    }
  },
  methods: {
    submitForm() {
      const rules = {
        'parent.son': [
          { required: true, message: "Please enter parent's son's name" }
        ],
        name: [
          { required: true, message: 'Please enter your name' }
        ]
      }

      validate(this.form, rules)
        .then(() => {
          alert('Form submitted successfully')
        })
        .catch(({ errors }) => {
          alert(errors[0].message)
        })
    }
  }
}
</script>